package com.example.product.service.impl;


import com.example.common.result.PageBean;
import com.example.model.product.pojo.Product;
import com.example.product.mapper.ProductMapper;
import com.example.product.service.ProductService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class ProductServiceimpl implements ProductService {
@Autowired
private ProductMapper productMapper;
    @Override
    public PageBean page(Integer page, Integer PageSize, String name, String description) {
        PageHelper.startPage(page, PageSize);
        List<Product> list = productMapper.page(name, description);
        Page<Product> p = (Page<Product>) list;
        return new PageBean(p.getTotal(),p.getResult());
    }

    @Override
    public void save(Product product) {
    productMapper.save(product);
    }

    @Override
    public Product selectById(Integer id) {
        Product product = productMapper.selectById(id);
        return product;
    }

    @Override
    public void deleteById(List<Integer> ids) {
        productMapper.deleteById(ids);
    }

    @Override
    public void update(Product product) {
        productMapper.update(product);
    }

}
